package org.awa.demo.opencv.init;

import lombok.extern.slf4j.Slf4j;
import org.awa.demo.opencv.service.IDemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class ApplicationRunnerListener implements ApplicationRunner {

    @Autowired
    private IDemoService demoService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        //前两次获取geojson文件会固定出错，这边先预热一下
        runKunMing();
        runKunMing();
    }

    private void runKunMing(){
        try {
            demoService.calByKunMing();
        } catch (Exception e) {
            e.printStackTrace();
            log.info("call runKunMing");
        }
    }
}
